﻿using Oya.Framework;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using Oya.Framework.GdiGaming;
using System.Drawing;
using System.Drawing.Drawing2D;

namespace Oya.UI.Process.GameScenes
{
    public class GameSceneMenu : GameScene
    {
        public override string Name
        {
            get
            {
                return "Menu";
            }

        }

        protected override void OnLoad(GameEngineEventArgs e)
        {
            base.OnLoad(e);

            OyaHudLayer hud = new OyaHudLayer();


            //BG
            BG bg = new BG();
            hud.Images.Add(bg);

            //label
            TitleStartLabel title = new TitleStartLabel();
            hud.Labels.Add(title);
        }

        /************/
        public class BG : OyaHudImage
        {
            protected override void OnLoad(GameEngineEventArgs e)
            {
                base.OnLoad(e);
                Bitmap bg = e.Engine.CurrentScene.GetImageAsset("background.png");

                OyaSprite spriteBg = new OyaSprite();
                spriteBg.SpriteSheetName = "background.png";
                spriteBg.SetFrameBounds(new Rectangle(Point.Empty, bg.Size));
                Sprites.Add(spriteBg);

                //va positionner le bg au millieu de la scene
                Position = new Vector2(bg.Width / 2, bg.Height / 2);
            }

            protected override void OnDraw(DrawEventArgs e)
            {
                base.OnDraw(e);
                HatchBrush _HatchBrush = new System.Drawing.Drawing2D.HatchBrush(System.Drawing.Drawing2D.HatchStyle.LightHorizontal, Color.FromArgb(48, Color.WhiteSmoke), Color.FromArgb(48, Color.DarkGray));
                e.PaintEventArgs.Graphics.FillRectangle(_HatchBrush, e.PaintEventArgs.ClipRectangle);
                _HatchBrush.Dispose();
            }
        }
    }

    internal class TitleStartLabel : OyaHudLabel
    {

        int _AlphaDelta = 5;
        int _AlphaStep = 5;
        protected override void OnLoad(GameEngineEventArgs e)
        {
            base.OnLoad(e);

            /****   mean the label process input *****************/
            ProcessInput = true;
            Text = "Oya - Start Game";
            FontSize = 42;
            BackColor = Color.Azure;
            TextColor = Color.Black;
            ZOrder = 10;

            OnUpdate(e);
        }

        protected override void OnDraw(DrawEventArgs e)
        {
            base.OnDraw(e);

            SolidBrush brsh = new SolidBrush(Color.FromArgb(_AlphaDelta, Color.DarkGray));
          //  e.PaintEventArgs.Graphics.FillRectangle(brsh, this.GetRectangleCollider);
        //brsh.Dispose()
        }
    }
}
